﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;
using System.Collections.Generic;
using Entity;
using BAL;
using Common;
namespace Web
{
    public partial class PolicyMain : System.Web.UI.Page
    {
        public static Module_Page Pages = new Module_Page();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!UserValidate.CheckLogin(this.Request, "MasterUser"))
            {
                Response.Write("<script type=\"text/javascript\">top.location.href='login.aspx';</script>");
                Response.Redirect("login.aspx");
                Response.End();
            }

            if (Request.QueryString["page"] != null && Request.QueryString["page"] != string.Empty)
            {
                if (PageValidate.IsNumber(Request.QueryString["page"]))
                {
                    Pages.PageNum = int.Parse(Request.QueryString["page"]);
                }
            }
            if (!IsPostBack)
            {
                LoadList();
            }
        }

        protected void lbSubject_DataBinding(object sender, EventArgs e)
        {
            Label lb = sender as Label;
            if (lb != null)
            {
                try
                {
                    if (lb.Text == "" || lb.Text == "0")
                    {
                        lb.Text = "";
                        return;
                    }
                    else
                    {
                        SubjectInfo item = Subject.GetSubjectInfoById(int.Parse(lb.Text));
                        if (item != null && item.Id != 0)
                        {
                            lb.Text = item.Name;
                        }
                    }
                }
                catch
                {
                    lb.Text = "";
                }
            }
        }
        protected void LoadList()
        {
            Pages.AllCount = TestPaperPolicyMain.GetT1Count();
            Pages.PageSize = 20;
            Pages.PageName = "PolicyMain.aspx?page=";
            Pages.Compute();
            PageLabel.Text = Pages.GetPage();
            IList<TestPaperPolicyMainInfo> userinfos = TestPaperPolicyMain.GetList(Pages.First, Pages.Max);
            UserLists.DataSource = userinfos;
            UserLists.DataBind();
        }

       
    }
}
